
// Copyright (C) 2007 Richard Uhler
// This file is part of Esiply.
//
// Esiply is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, Version 2,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _FUNCTION_H_
#define _FUNCTION_H_

#include "Object.h"
#include "Value.h"

// A Function is any Object which implements call and 
// construct methods.

class Function : public Object
{
public:
    Function();
    virtual bool isCallable() const;

    // Ecma 13.2.1 [[Call]]
    // this_obj can't be an Object* because this_obj may be Null::null.
    virtual Value* call(Scope* scope, Value* this_obj, List* args) = 0;

    // Ecma 13.2.2 [[Construct]]
    virtual Value* construct(List* args) = 0;

    // Ecma 15.3.5.3 [[HasInstance]]
    // This can't return a Boolean* because it might return an exception.
    Value* hasInstance(Value* value);

    static Function* prototype;
	//Synchronized function
	int get_sync() const;
	void set_sync(int sync);
private:
    // Let's not have copying or assigning...
    Function(const Function& rhs);
    Function& operator=(const Function& rhs);
	//Synchronized function
	int m_sync;
};

#endif//_FUNCTION_H_

